﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cqrs.Common;

namespace Cqrs.CodeGeneration.CSharp
{
    public class CSharpGenerator : GeneratorModelBase
    {
        public List<CommandEventGeneratorModel> CommandEventGeneratorModels { get; set; }
        public CSharpGenerator(
                    StateMachine stateMachine,
                    List<CommandEvent> adHocMethods,
                    string domainNamespace,
                    string domainName,
                    IList<DomainProperty> domainProperties,
                    string smfFile)
            : base(stateMachine,
                    adHocMethods,
                    domainNamespace,
                    domainName,
                    domainProperties,
                    smfFile)
        {
            this.CommandEventGeneratorModels =
                CommandEventGeneratorModel.BuildCommandEventGeneratorModelList(
                    this.StateMachine, this.AdHocMethods);
        }

        public override string DomainCode
        {
            get
            {
                return new DomainClass(this).TransformText();
            }
        }

        public override string EventCode
        {
            get
            {
                return new EventClass(this).TransformText();
            }
        }

        public override string CommandCode
        {
            get
            {
                return new CommandClass(this).TransformText();
            }
        }

        public override string CommandHandlerCode
        {
            get
            {
                return new CommandHandlers(this).TransformText();
            }
        }

        public override string TestCode
        {
            get
            {
                return new IntegrationsTests(this).TransformText();
            }
        }
    }
}
